deleted /dev/sda1, recreated it, and things are fine?

General support questions
Post Reply
glenr
Posts: 2
Joined: 2015/01/04 03:23:56

deleted /dev/sda1, recreated it, and things are fine?

Post by glenr » 2015/01/04 03:37:28

First, thank you to CentOS community and developers, and Red Hat for such a great OS.

I used DD from a Live USB drive (fedora) to image my CentOS machine's 250GB system drive to a 500GB drive. I was following a blog that was showing me the instructions on how to grow a PV/VG and then the LV. One of the steps the blog said (I wish I saved the url now). was to delete the initial PV partition: sda1, then recreate it with the new size of the disk, reboot, and then use pvresize. Then use the lvresize for the lv's I wanted to grow. I was sceptical that this could be done, but since I had the original 250GB drive, I thought it would be good practice to try.

I did as reccomended, and it worked great. But, what messes with my head, why was I able to delete sda1 with the system booted and running and the machine did not go nuts or crash?

That drive only had sda1, and a swap paritions and all my VG's were on sda1 that was the only PV for my system.

I have been looking into places on the internet to explain how this is possible, but I dont think I have the right search terms. Can someone explain to me why I was able to do this and be successful, or point me in the right direction so I can learn why I was able to delete the sda1 parition, recreate it with the system running and everything was fine?

Thank you!
-Glen

User avatar
mikeCentos7
Posts: 14
Joined: 2014/09/13 07:35:05
Location: Poland

Re: deleted /dev/sda1, recreated it, and things are fine?

Post by mikeCentos7 » 2015/01/04 08:39:18

Partitions are only a logical representation of some hdd's space chunk. Until the data which was written to a particular block device is not over-written should be still there. However, you have to keep in mind that partitions has to be recreated within the same cylinder range (so the data should spawn the same number of disk's sectors). At least that's the way how I see it. I have never had an issue with recreating the partitions with bigger/smaler size by removing them first.Of course wit re-sizing you also have to remember about the filesystem's size as it can be different than partition's. General rule is to not have smaller partition than the filesystem which is installed on it. Well, you would not be even able to have such a partition. At least not with ext{2,3,4} filesystems. Also when you are resizing LVM partitions, for making them bigger, you don't have to remove them first.

Still, the above is just my way of thinking about this stuff. Could be wrong. :)
Living The Linux

User avatar
TrevorH
Forum Moderator
Posts: 29120
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: deleted /dev/sda1, recreated it, and things are fine?

Post by TrevorH » 2015/01/04 12:10:00

The kernel keeps copies of the partition tables in memory and will not refresh that copy if any partition is in use. When you manipulate the partition table on disk, it has no effect on the running system until either everything in use on there is no longer in use or you reboot.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

Cookacoo
Posts: 15
Joined: 2014/09/26 00:03:53

Re: deleted /dev/sda1, recreated it, and things are fine?

Post by Cookacoo » 2015/01/05 02:06:59

I used DD from a Live USB drive (fedora) to image my CentOS machine's 250GB system drive to a 500GB drive.
You were booted from a live disk, meaning you were not running from or booted from /dev/sda1, nor were you using the /dev/sda1 while you were making your changes. Then unmounted you would have gotten errors every time you tried to execute something that wasnot stored in cache. something along the lines of command not found.

=D Hope this helps.

glenr
Posts: 2
Joined: 2015/01/04 03:23:56

Re: deleted /dev/sda1, recreated it, and things are fine?

Post by glenr » 2015/01/05 03:50:07

I am sorry, I did not describe what I did correctly.
After I used the Fedora Live USB to DD the original drive to the new drive, I then booted from the new 500GB drive, and did the partition changes booted from the system on sda.

Sorry about the confusion, and thank you for all your help!

-Glen

Post Reply

Return to “CentOS 7 - General Support”