With pdfbook2 it is possible to convert a pdf from A4 format to one which one can print onto A4 format, but then fold the pages in the middle and get a booklet of A5 format. I would like to go one step further, and reduce this to A6: Print on four pages onto one sheet of A4 paper, cut it in the middle, and then fold the resulting A5 paper to get a booklet of A6 size. pdfbook2 doesn't seem to have an option for this, running it twice does not produce the desired result, neither does printing the result with two pages per sheet of paper.
muk.li's questions
I am trying to save data from a system that used to live on a tiny usb stick, but I suspect a hardware failure. The system came out of a suspend with the root filesystem in read only, and instead of understanding that it was about to die and that I should try to save some data, I opted for a quick reboot, but was not able since then to get back into it in any way.
It is an Ubuntu 18.04 with encrypted root filesystem chosen at the time of its installation, so I suppose that is LUKS. If I try to boot into it now, I get the violet screen, then an error message, then I get the (initramfs)
prompt. I've tried to do a manual fsck of the filesystem as per the instructions here, but keep getting i/o errors of the following kind,
Buffer I/O error on dev dm-1, logical block 4, lost async page page write
and
print_req_error: critical target error, dev sda, sector 9896192 flags 801
.
It ends with
fsck.ext4: unable to set superblock flags on /dev/mapper/ubuntu--vg-root
,
And telling me that the filesystem still has errors. I tried specifying backup superblocks, but without success.
I now tried to put the stick into a healthy system and decrypt and mount it and see if I can still save something. When inserting the stick I am prompted for the key, and apparently it decrypts it, see the syslog:
Dec 21 03:38:42 X1 kernel: [36919.500937] usb 2-1: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd
Dec 21 03:38:42 X1 kernel: [36919.521737] usb 2-1: New USB device found, idVendor=0781, idProduct=5583, bcdDevice= 1.00
Dec 21 03:38:42 X1 kernel: [36919.521742] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Dec 21 03:38:42 X1 kernel: [36919.521745] usb 2-1: Product: Ultra Fit
Dec 21 03:38:42 X1 kernel: [36919.521748] usb 2-1: Manufacturer: SanDisk
Dec 21 03:38:42 X1 kernel: [36919.521751] usb 2-1: SerialNumber: 4C530001210812112290
Dec 21 03:38:42 X1 kernel: [36919.523118] usb-storage 2-1:1.0: USB Mass Storage device detected
Dec 21 03:38:42 X1 kernel: [36919.523697] scsi host1: usb-storage 2-1:1.0
Dec 21 03:38:42 X1 mtp-probe: checking bus 2, device 3: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1"
Dec 21 03:38:42 X1 mtp-probe: bus: 2, device: 3 was not an MTP device
Dec 21 03:38:42 X1 upowerd[1354]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0
Dec 21 03:38:42 X1 upowerd[1354]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-1
Dec 21 03:38:43 X1 kernel: [36920.553722] scsi 1:0:0:0: Direct-Access SanDisk Ultra Fit 1.00 PQ: 0 ANSI: 6
Dec 21 03:38:43 X1 kernel: [36920.554585] sd 1:0:0:0: Attached scsi generic sg1 type 0
Dec 21 03:38:43 X1 kernel: [36920.554754] sd 1:0:0:0: [sdb] 489160704 512-byte logical blocks: (250 GB/233 GiB)
Dec 21 03:38:43 X1 kernel: [36920.555633] sd 1:0:0:0: [sdb] Write Protect is on
Dec 21 03:38:43 X1 kernel: [36920.555641] sd 1:0:0:0: [sdb] Mode Sense: 43 00 80 00
Dec 21 03:38:43 X1 kernel: [36920.555952] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Dec 21 03:38:43 X1 kernel: [36920.566040] sdb: sdb1 sdb2 < sdb5 >
Dec 21 03:38:43 X1 kernel: [36920.568791] sd 1:0:0:0: [sdb] Attached SCSI removable disk
Dec 21 03:38:43 X1 kernel: [36920.961099] EXT4-fs (sdb1): INFO: recovery required on readonly filesystem
Dec 21 03:38:43 X1 kernel: [36920.961100] EXT4-fs (sdb1): write access unavailable, cannot proceed (try mounting with noload)
Dec 21 03:38:43 X1 gnome-shell[1828]: Unable to mount volume 767 MB Volume: Gio.IOErrorEnum: Error mounting /dev/sdb1 at /media/peter/0b776e27-d039-4fc5-ad20-462e5e36e031: cannot mount /dev/sdb1 read-only
Dec 21 03:38:50 X1 gnome-shell[1828]: Unable to mount volume 250 GB Encrypted: Gio.IOErrorEnum: Operation was cancelled
Dec 21 03:38:50 X1 udisksd[1004]: Unlocked LUKS device /dev/sdb5 as /dev/dm-3
Now
$ sudo fsck /dev/dm-3 -y
fsck from util-linux 2.31.1
Nothing else. Not sure if that's good or bad news, or I am on the wrong track maybe. Just trying to mount it I get unknown filesystem type 'LVM2_member'.
The following also doesn't help:
$ udisksctl mount -b /dev/dm-3
Object /org/freedesktop/UDisks2/block_devices/dm_2d3 is not a mountable filesystem.
Now I still don't really understand how LVM and LUKS work, and I don't know how broken the stick is. What could I try next?
EDIT: I am making another attempt at getting into the disk, inserting it into a healthy system. I get asked for the password, the system is apparently decrypted.
Jan 4 13:15:59 X1 kernel: [258125.811027] usb 2-2: new SuperSpeed Gen 1 USB device number 6 using xhci_hcd
Jan 4 13:15:59 X1 kernel: [258125.835919] usb 2-2: New USB device found, idVendor=0781, idProduct=5583, bcdDevice= 1.00
Jan 4 13:15:59 X1 kernel: [258125.835924] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 4 13:15:59 X1 kernel: [258125.835927] usb 2-2: Product: Ultra Fit
Jan 4 13:15:59 X1 kernel: [258125.835930] usb 2-2: Manufacturer: SanDisk
Jan 4 13:15:59 X1 kernel: [258125.835933] usb 2-2: SerialNumber: 4C530001210812112290
Jan 4 13:15:59 X1 kernel: [258125.837229] usb-storage 2-2:1.0: USB Mass Storage device detected
Jan 4 13:15:59 X1 kernel: [258125.837738] scsi host1: usb-storage 2-2:1.0
Jan 4 13:15:59 X1 mtp-probe: checking bus 2, device 6: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-2"
Jan 4 13:15:59 X1 mtp-probe: bus: 2, device: 6 was not an MTP device
Jan 4 13:15:59 X1 upowerd[1314]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0
Jan 4 13:15:59 X1 upowerd[1314]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2
Jan 4 13:16:00 X1 kernel: [258126.856090] scsi 1:0:0:0: Direct-Access SanDisk Ultra Fit 1.00 PQ: 0 ANSI: 6
Jan 4 13:16:00 X1 kernel: [258126.856856] sd 1:0:0:0: Attached scsi generic sg1 type 0
Jan 4 13:16:00 X1 kernel: [258126.856963] sd 1:0:0:0: [sdb] 489160704 512-byte logical blocks: (250 GB/233 GiB)
Jan 4 13:16:00 X1 kernel: [258126.857870] sd 1:0:0:0: [sdb] Write Protect is on
Jan 4 13:16:00 X1 kernel: [258126.857875] sd 1:0:0:0: [sdb] Mode Sense: 43 00 80 00
Jan 4 13:16:00 X1 kernel: [258126.858195] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jan 4 13:16:00 X1 kernel: [258126.867874] sdb: sdb1 sdb2 < sdb5 >
Jan 4 13:16:00 X1 kernel: [258126.869975] sd 1:0:0:0: [sdb] Attached SCSI removable disk
Jan 4 13:16:00 X1 kernel: [258127.138645] EXT4-fs (sdb1): INFO: recovery required on readonly filesystem
Jan 4 13:16:00 X1 kernel: [258127.138646] EXT4-fs (sdb1): write access unavailable, cannot proceed (try mounting with noload)
Jan 4 13:16:00 X1 gnome-shell[1852]: Unable to mount volume 767 MB Volume: Gio.IOErrorEnum: Error mounting /dev/sdb1 at /media/peter/0b776e27-d039-4fc5-ad20-462e5e36e031: cannot mount /dev/sdb1 read-only
Jan 4 13:16:03 X1 systemd-resolved[924]: Got packet on unexpected IP range, refusing.
Jan 4 13:16:03 X1 systemd-resolved[924]: Got packet on unexpected IP range, refusing.
Jan 4 13:16:05 X1 gnome-shell[1852]: Unable to mount volume 250 GB Encrypted: Gio.IOErrorEnum: Operation was cancelled
Jan 4 13:16:05 X1 udisksd[1095]: Unlocked LUKS device /dev/sdb5 as /dev/dm-3
If I try to mount /dev/dm-3 I get only.
unknown filesystem type 'LVM2_member'.`
lvmdiskscan shows me the volume:
/dev/mapper/luks-477637dc-44d2-4076-9519-194cc4bf46c6 [ 232,53 GiB] LVM physical volume
But lvs
or lvscan
don't show me anything related to the usb stick.
I assume it is failing and has gone into a kind of read-only mode. I wonder if there is some way to mount the root partion /dev/sdb5 read-only to still try and get some stuff out from it? Maybe I could dd /dev/dm-3
somewhere else and try to mount it?
Assuming I want to track the times I spend editing a set of files, and log them to a file, as I could do from the commandline using the time
command:
time vim test.txt
I get
real 0m8.149s
user 0m0.056s
sys 0m0.008s
Fine. Now if I want to append its output to a log file,
time vim test.txt >> my.log
Well, of course I'd make that more elaborate eventually to give me more information, but I don't get past the first step, the terminal just hangs with the following warning:
Vim: Warning: Output is not to a terminal
The redirection interferes with vim needing the terminal. What would be a good workaround here?
Edit: One workaround could be the following:
time gnome-terminal -x vim test.txt >> my.log
Which opens a new terminal window in which vim is executed. I'd prefer to stay in the same window, but could also live with this workaround.
Edit: Didn't quite work either, it seemed to do in some test, in some other it backgrounded, thus not measuring the time used. In my script now I did something like that:
/usr/bin/time -o tmpfile vim test.txt
echo some stuff `cat tmpfile` some more stuff >>my.log
rm tmpfile
Seems to work.
Edit: It works only as long as one doesn't have two processes using the same tmpfile
. In order to avoid that one can use the pid of the script being executed as part of the temporary file name:
/usr/bin/time -o $$.tmp vim test.txt
echo some stuff `cat $$.tmp` some more stuff >>my.log
rm $$.tmp
If I search for a word in evince I get a list of search results on the left, with page numbers. These page numbers though are absolute page numbers of the pdf, not taking into account different page ranges for frontmatter (in roman numbers) and mainmatter. The following is from a minimum pdf of four pages, numbered i,ii,1,2, with a hit for my search on every page. Evince shows 1,2,3,4 instead. It can handle the page numbers correctly in the page field above. Is there another pdf viewer which does this correctly?
Assuming I want to grep
all packages used in a tex file:
$ grep usepackage my.tex
will do, with (as far as I can see) one exception: If a package gets loaded with that many options that the author of the file decided to insert line breaks, as in
\usepackage[option1,
option2,
option3]{thepackage}
Would there be a way to tell grep to continue parsing the file until it hits the }
?
Ideally I would only get the thepackage
as output, so that I could possibly iterate over it, such as:
$ for i in `locate `my grep command`.sty`
do
grep \\\\newcommand{\\\\createstrouble} $i
done
in order to quickly find a package in which a command \createstrouble
is defined?
EDIT: One further complication: I have a \usepackage
command as follows:
\usepackage[pdftitle={My Title},
pdfauthor={My Author}]{hyperref}
EDIT: I understood that this approach doesn't work for my purpose, which was to find out conflicting packages. Primarily so, because a package loaded by \usepackage{something}
pulls in more packages through RequirePackage
which one will not have on ones radar. Better to work with the logfile, possibly using \listfiles
in ones preamble, producing a list of files loaded, and grepping through ones texmf
directory for the actual command name used by different packages.
It uses more than 100 MB on my tiny system, I can't really imagine this all just being the configuration of only the chrome browser. How would I reduce its size?
If you uninstall a package, but don't purge it, dpkg -l
will show it as rc
, meaning removed, but config files are left. Is there an easy way to see how much space is still used by such a package?
Having hlsearch enabled, if I use something like :%s/search term/replacement term/gc
vim will highlight all occurrences of the search term by using black foreground on yellow background, but for the currently selected one it uses black foreground on white background, which is hard to spot due to the syntax highlighting pattern for latex files already using this for something else. How would I change the background colour of the currently selected result to, say, pink?