View previous topic :: View next topic |
Author |
Message |
katfish Tux's lil' helper
Joined: 14 Nov 2011 Posts: 147
|
Posted: Wed Aug 13, 2014 5:45 pm Post subject: Repartitioning system SSD |
|
|
I face more and more bad write speeds on the SSD of my notebook.
After some research I found out that i missed to correctly align the partitions.
Also the cipher i have choosen for the disk encryption is no longer state of the art.
So I want to recreate and reencrypt the root and swap partition now.
My current root and swap are over LVM on the luks encrypted SSD.
To backup the root fs I want to boot from a live system, unlock the LVs
and simply: dd if=/dev/mapper/vg-root | gzip > /mnt/usb-drive/vg-root.img.gz
after repartitioning: gunzip -c /mnt/usb-drive/vg-root.img.gz | dd if=/dev/mapper/vg-root.
Will that work? I really do not want to end up in a desaster...
Every feedback is welcome |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3095
|
Posted: Wed Aug 13, 2014 8:41 pm Post subject: |
|
|
The general idea it will work. You have to work on details though.
In dd's command line:
'if' stands for Input File.
'of' stands for Output File
I'm not sure if dd allows omiting either of or if, but it definitely does allow both, if=/dev/stdin and of=/dev/stdout.
Also, no idea if it still gives a significant boost in case of ssd, but it used to be a good idea to increase buffer size with param like bs=30M (or 60M, since disks tend to have this big cache)
Gzip command line:
'-c' in gzip's command stand for "compress", so don't launch gunzip -c. Gunzip equals to 'gzip -d': decompress. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21431
|
Posted: Wed Aug 13, 2014 9:47 pm Post subject: |
|
|
szatox wrote: | I'm not sure if dd allows omiting either of or if, but it definitely does allow both, if=/dev/stdin and of=/dev/stdout. | That is easy to test. It does allow omitting either or both and it defaults them to stdin/stdout accordingly.
OP: although your technique will work, it is wrong. You should never use dd to move a filesystem because doing so copies all the free space. Additionally, for SSDs, you guarantee that you write to every sector on output, which marks the entire output partition as used from the perspective of the SSD firmware. You should instead mount the filesystem from a live environment and copy its files over, such as with rsync -a or cp -a. In either case, take care to copy all metadata, including hardlinks and xattrs. |
|
Back to top |
|
|
frostschutz Advocate
Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Wed Aug 13, 2014 10:51 pm Post subject: |
|
|
What do your partitions look like? (parted /dev/... unit s print).
The gzip won't be very effective. If there are trimmed areas, they will show up as random data due to the encryption. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21431
|
Posted: Thu Aug 14, 2014 1:56 am Post subject: |
|
|
frostschutz wrote: | The gzip won't be very effective. If there are trimmed areas, they will show up as random data due to the encryption. | As I read the first post, he plans to dd from the logical volume device node that represents the decrypted filesystem. The raw drive will look random as you say, but he will be reading plaintext. |
|
Back to top |
|
|
katfish Tux's lil' helper
Joined: 14 Nov 2011 Posts: 147
|
Posted: Thu Aug 14, 2014 11:42 am Post subject: |
|
|
thank you for your replies.
szatox wrote: | The general idea it will work. You have to work on details though.
In dd's command line:
'if' stands for Input File.
'of' stands for Output File
I'm not sure if dd allows omiting ....
Gzip command line:
'-c' in gzip's command stand for "compress", so don't launch gunzip -c. Gunzip equals to 'gzip -d': decompress. |
szatox, thank you for the hints. i double checked the cmds. gunzip -c reads data from stdin. dd can do both simultaneously (read/write to block or file)
Hu wrote: | frostschutz wrote: | The gzip won't be very effective. If there are trimmed areas, they will show up as random data due to the encryption. | As I read the first post, he plans to dd from the logical volume device node that represents the decrypted filesystem. The raw drive will look random as you say, but he will be reading plaintext. |
I ran dd from the decrypted fs. the img.gz is now 1/3 of the partition size
During writing here, the backup restore just finished, and after fixing UUIDs in Grub, the system booted succesfully |
|
Back to top |
|
|
|