Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Repartitioning system SSD
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
katfish
Tux's lil' helper
Tux's lil' helper


Joined: 14 Nov 2011
Posts: 147

PostPosted: Wed Aug 13, 2014 5:45 pm    Post subject: Repartitioning system SSD Reply with quote

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
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1746

PostPosted: Wed Aug 13, 2014 8:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13845

PostPosted: Wed Aug 13, 2014 9:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2970
Location: Germany

PostPosted: Wed Aug 13, 2014 10:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13845

PostPosted: Thu Aug 14, 2014 1:56 am    Post subject: Reply with quote

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
View user's profile Send private message
katfish
Tux's lil' helper
Tux's lil' helper


Joined: 14 Nov 2011
Posts: 147

PostPosted: Thu Aug 14, 2014 11:42 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum