7

I saw in https://unix.stackexchange.com/a/501410/ that gparted can move a partition in a disk.

Since gparted is said to be a frontend of parted, what is the corresponding command(s) using parted to move a partition anywhere? Sorry, I only know parted has resizepart which only changes the end of a position, instead of moving a whole partition.

Thanks.

Tim
  • 101,790

1 Answers1

10

parted used to be able to move partitions and resize (certain) file systems, but this feature was removed in version 3.0 because it was deemed to difficult to maintain.

Stephen Kitt
  • 434,908
  • Thanks. How would you move a partition, if you can only use parted now? If you can use something else, what would you use for moving a partition? – Tim Feb 22 '19 at 13:42
  • 3
    I would use gparted. I avoid partitions anyway, so I never need to move or resize partitions; I use LVM everywhere, and skip partitions entirely on non-bootable disks. – Stephen Kitt Feb 22 '19 at 13:46
  • " I use LVM everywhere, and skip partitions entirely on non-bootable disks". (1) Do you not use LVM on bootable disks? Why (2) Do you partition bootable disks? (3) Speaking of that, I'd appreciate if you could also consider https://unix.stackexchange.com/questions/502305/how-can-i-split-a-monolithic-partition-into-two-one-for-and-one-for-home – Tim Feb 22 '19 at 13:47
  • 1
    On bootable disks, I have whatever partitions are needed to boot the system (such as the ESP on EFI systems, or /boot on BIOS or U-boot systems), and one big partition occupying all the available space, which is used as a PV in LVM. On non-bootable disks, I use the entire disk as a PV, with no partitions at all. – Stephen Kitt Feb 22 '19 at 13:51
  • If I understand you correctly, I don't have the luxury to have more than one disks in my laptop. My laptop has only one disk (which is thus a bootable disk). So I think I have to partition it so that / and /home are in different partitions? – Tim Feb 22 '19 at 13:53
  • No, you can have one partition for the ESP, and another partition which you use with LVM: that large partition (/dev/sda2) is a PV, used in a VG, containing however many LVs you want (one for / and one for /home). – Stephen Kitt Feb 22 '19 at 14:01
  • Shall I use LVM on the monolithic partition (in the linked question) to create a logical volume for / and another for /home? Can that help to protect / and /home from each other? Can you reply to the linked question for how to use LVM to do that step by step? Much appreciated. I haven't used LVM before – Tim Feb 22 '19 at 14:02
  • It's not very meaningful to use LVM on a single disk, maybe you're ready to add the second disk in the future, then you can add it to you VG, providing almost unlimited storage upgrade ability. Step by step tutorial should be googled by yourself, with the assumption that you know the basic concepts of LVM. – 炸鱼薯条德里克 Feb 22 '19 at 14:14
  • @炸鱼薯条德里克 I find LVM useful on single disk systems too, it makes it much easier to resize “partitions”. – Stephen Kitt Feb 22 '19 at 14:17
  • @炸 (1) Can LVM help to protect / and /home on a disk from each other? by separate logical volumes, separate volume groups, or separate PVs ? (2), "there is a learning curve" in https://unix.stackexchange.com/a/501410/674 scares me. – Tim Feb 22 '19 at 14:20
  • Well, I didn't see how much easier it gets. It can't automatically (or magically?) resize your filesystem anyway. – 炸鱼薯条德里克 Feb 22 '19 at 14:21
  • @Tim dont know what you mean by protect – 炸鱼薯条德里克 Feb 22 '19 at 14:22
  • @炸 when your / is messed up, you data in /home can still be intact. Is my question understandable now? – Tim Feb 22 '19 at 14:23
  • Then why can't partition provide this functionality? In reality, you can't do this, since you always needs to write to both filesystem to do your daily work, one careless step of root might destroy all your data. Want to protect your data from your cat typing on your keyboard? Hide your keyboard or do backup. – 炸鱼薯条德里克 Feb 22 '19 at 14:27
  • @炸 partitions can of course provide that protection. I am asking if LVM can also provide that security, since LVM can provide additional flexibility. (Btw, I can't afford my living, so no cat) – Tim Feb 22 '19 at 14:41
  • 1
    LVM provides the same level of protection as partitions or any other file system container: file system corruption is limited to a single file system, and one file system running out of free space doesn’t affect others. However any mounted file system is liable to be “messed up” by a program running amok. – Stephen Kitt Feb 22 '19 at 15:15
  • Thanks. I'd appreciate if you could also consider https://unix.stackexchange.com/questions/502437/how-shall-i-create-a-physical-volume-from-a-partition-containing – Tim Feb 23 '19 at 00:56
  • I guess "I would use gparted" on bootable disks. What would you use if you only have command line interface working then? – Tim Feb 27 '19 at 04:53
  • If I need to move partitions, I’ll arrange things so that I can run gparted; typically, boot from a recovery USB stick with a GUI and gparted. – Stephen Kitt Feb 27 '19 at 06:35