LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   created filesystem now I have an altered partition table. (https://www.linuxquestions.org/questions/linux-newbie-8/created-filesystem-now-i-have-an-altered-partition-table-4175515924/)

project722 08-22-2014 06:48 AM

created filesystem now I have an altered partition table.
 
My partition table looked like this at first:

/dev/sda1 * 2048 32505855 16251904 83 Linux
/dev/sda2 32507902 33552383 522241 5 Extended
/dev/sda3 32505856 32507901 1023 83 Linux
/dev/sda5 32507904 33552383 522240 82 Linux swap / Solaris


/dev/sda3 was a new test partition that I created with fdisk. I exited fdisk then ran the following command (inside of fdisks interactive mode) to create a filesystem on it:

mkfs -t ext4 /dev/sda3

My partition table now looks like this after committing the changes:

/dev/sda1 0 33447330 16723665 83 Linux native
/dev/sda2 u 33447330 33543720 48195 82 Linux swap
/dev/sda3 0 33543720 16771860 5 Whole disk

And the label changed to "Sun Disk Label"

Did I screw something up? All I did was drop a FS on the sda3 partition. I'm afraid to reboot now. I am running Ubuntu 14.04TLS kernel version 3.13.0

project722 08-22-2014 07:10 AM

Edit - "I exited fdisk then ran the following command (inside of fdisks interactive mode) to create a filesystem on it:"

Sorry about this confusion - I never exited FDSIK. Not sure if that even matters but just wanted to clear that up.

syg00 08-22-2014 08:46 AM

You'd better give a *lot* better list of exactly what you did - in order and how.

For example - how did you do a mkfs without exiting fdisk ?. From a different vt ?. I really hope the answer to that is "no".

EDDY1 08-22-2014 09:50 AM

If you saved the changes yiu may have problems with fstab, because your swap just changed from sda5 ti sda3. If you're still booted to system, you'll definately want to edit fstab.

project722 08-22-2014 11:00 AM

Syg00 - Here is the exact command sequence. I have no idea how it let me do a mkfs inside of fdisk but it looks like it did and to be honest, I thought I had exited fdisk. It was the same shell/VT.

EDDY1 - No the system is still booted. Any help on what I can do to fstab to reverse this or anything else I can do is very much appreciated.

Here goes:

sudo fdisk /dev/sda
[sudo] password for brian:

Command (m for help): p

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003d501

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 32505855 16251904 83 Linux
/dev/sda2 32507902 33552383 522241 5 Extended
/dev/sda5 32507904 33552383 522240 82 Linux swap /

Solaris

Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): p
Partition number (1-4, default 3): 3
First sector (32505856-33554431, default 32505856):
Using default value 32505856
Last sector, +sectors or +size{K,M,G} (32505856-32507901, default

32507901):
Using default value 32507901

Command (m for help): p

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003d501

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 32505855 16251904 83 Linux
/dev/sda2 32507902 33552383 522241 5 Extended
/dev/sda3 32505856 32507901 1023 83 Linux
/dev/sda5 32507904 33552383 522240 82 Linux swap /

Solaris

Partition table entries are not in disk order

Command (m for help): mkfs -t ext4 /dev/sda3
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or

resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
brian@ubuntuvbox:~$ sudo fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003d501

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 32505855 16251904 83 Linux
/dev/sda2 32507902 33552383 522241 5 Extended
/dev/sda3 32505856 32507901 1023 83 Linux
/dev/sda5 32507904 33552383 522240 82 Linux swap /

Solaris

Partition table entries are not in disk order

Command (m for help): sudo mkfs -t ext4 /dev/sda3
Building a new sun disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or

resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
brian@ubuntuvbox:~$ p
p: command not found
brian@ubuntuvbox:~$ cat /proc/mounts
rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
udev /dev devtmpfs rw,relatime,size=244068k,nr_inodes=61017,mode=755 0 0
devpts /dev/pts devpts

rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=50724k,mode=755 0 0
/dev/disk/by-uuid/1566d285-de09-408d-8b14-c43d82fe0dfa / ext4

rw,relatime,errors=remount-ro,data=ordered 0 0
none /sys/fs/cgroup tmpfs rw,relatime,size=4k,mode=755 0 0
none /sys/fs/fuse/connections fusectl rw,relatime 0 0
none /sys/kernel/debug debugfs rw,relatime 0 0
none /sys/kernel/security securityfs rw,relatime 0 0
none /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
none /run/shm tmpfs rw,nosuid,nodev,relatime 0 0
none /run/user tmpfs

rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755 0 0
none /sys/fs/pstore pstore rw,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc

rw,nosuid,nodev,noexec,relatime 0 0
systemd /sys/fs/cgroup/systemd cgroup

rw,nosuid,nodev,noexec,relatime,name=systemd 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse

rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
gvfsd-fuse /home/brian/.gvfs fuse.gvfsd-fuse

rw,nosuid,nodev,relatime,user_id=0,group_id=0 0 0
brian@ubuntuvbox:~$ fdisk /dev/sda
fdisk: unable to open /dev/sda: Permission denied
brian@ubuntuvbox:~$ sudo fdisk /dev/sda

Command (m for help): p

Disk /dev/sda (Sun disk label): 255 heads, 63 sectors, 2088 cylinders
Units = sectors of 1 * 512 bytes

Device Flag Start End Blocks Id System
/dev/sda1 0 33447330 16723665 83 Linux native
/dev/sda2 u 33447330 33543720 48195 82 Linux swap
/dev/sda3 0 33543720 16771860 5 Whole disk

Command (m for help): l

0 Unassigned 4 SunOS usr 8 SunOS home 82 Linux

swap
1 Boot 5 Whole disk 9 SunOS alt secto 83 Linux

native
2 SunOS root 6 SunOS stand a SunOS cachefs 8e Linux

LVM
3 SunOS swap 7 SunOS var b SunOS reserved fd Linux

raid auto

Command (m for help): l

0 Unassigned 4 SunOS usr 8 SunOS home 82 Linux

swap
1 Boot 5 Whole disk 9 SunOS alt secto 83 Linux

native
2 SunOS root 6 SunOS stand a SunOS cachefs 8e Linux

LVM
3 SunOS swap 7 SunOS var b SunOS reserved fd Linux

raid auto

Command (m for help): ^Cbrian@ubuntuvbox:~$ p
p: command not found
brian@ubuntuvbox:~$ sudo fdisk /dev/sda

Command (m for help): p

Disk /dev/sda (Sun disk label): 255 heads, 63 sectors, 2088 cylinders
Units = sectors of 1 * 512 bytes

Device Flag Start End Blocks Id System
/dev/sda1 0 33447330 16723665 83 Linux native
/dev/sda2 u 33447330 33543720 48195 82 Linux swap
/dev/sda3 0 33543720 16771860 5 Whole disk


Here is the current output of my fstab file.

cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=1566d285-de09-408d-8b14-c43d82fe0dfa / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=e0de16fa-8e60-4237-af98-3ebaafb594e5 none swap sw 0 0

EDDY1 08-22-2014 03:54 PM

Your drive is only 17.5 Gig you may want to add another if yoy want seperate partitions.
But any way you have soo many fdisk entries can you post the end result. In other words stick with 1, also you don't have to worry about the order of your partitions it will still boot will still boot if fstab is set right.

project722 08-22-2014 04:21 PM

Its in Virtual Box on my Win 7 machine so I can't add a drive. This box is for testing purposes only and not in production however I do have some server apps installed that I'd rather not have to deal with if I did a re-install. What do you mean by so many fdisk entries? Where do you see that? And how do I fix fstab so this thing will come up the way it was before after a reboot? Thanks!

JeremyBoden 08-22-2014 08:34 PM

Is this bit in the middle of fdisk significant?
Quote:

WARNING: Re-reading the partition table failed with error 16: Device or
resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)

EDDY1 08-22-2014 10:53 PM

I missed it. I guess OP needs to run partprobe to make changes now. Unless the changes to swap aren't going to affect on next reboot. But yes I think that it's signifiacnt

rknichols 08-22-2014 11:28 PM

What happened was that when you typed "sudo mkfs ...", fdisk took that initial "s" as a command to create a new empty Sun disk label, blowing away your current partition table.
Quote:

Originally Posted by JeremyBoden (Post 5225703)
Is this bit in the middle of fdisk significant?
Code:

WARNING: Re-reading the partition table failed with error 16: Device or
resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)


It means that your messed up partition table has not taken effect yet. If you can patch things back the way they were before you reboot, all will be well. If you try to reboot before restoring the partition table to its proper state, the reboot will fail and you will be in a data recovery situation.

Without rebooting or running partprobe, run fdisk again, delete all of the current partitions, and then re-create the original partition structure according to the listing you have posted. You will then need to re-install the boot loader since the primary boot loader in the MBR probably got wiped out when the Sun disk label was created.

project722 08-23-2014 05:06 AM

rknichols - Is that expected behavior or a bug perhaps? Would it have failed if not for the sudo? And what about the options specified? Even if sudo wasn't used in the command, I would think that since I specified /dev/sda3 that it would at least throw an error here or message saying "ok, I can't give you a new disk label because you have said you wanted this only to apply to sda3"?

Anyway, I will give the instructions a shot and post back here with the outcome.

project722 08-23-2014 06:21 AM

Ok here is where I am at now:
==================================================================================================== ========================
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 82
Changed system type of partition 5 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xde2b5a72

Device Boot Start End Blocks Id System
/dev/sda1 2048 32505855 16251904 83 Linux
/dev/sda2 32507902 33552383 522241 5 Extended
/dev/sda5 32509950 33552383 521217 82 Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
brian@ubuntuvbox:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=1566d285-de09-408d-8b14-c43d82fe0dfa / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=e0de16fa-8e60-4237-af98-3ebaafb594e5 none swap sw 0 0

==================================================================================================== ========================
That is as close as I could get the structure to the way it was BEFORE I did anything. Below is the way it was originally:

/dev/sda1 * 2048 32505855 16251904 83 Linux
/dev/sda2 32507902 33552383 522241 5 Extended
/dev/sda5 32507904 33552383 522240 82 Linux swap /

As you can see - sda5/swap here in the original exist in the same space(almost) as sda2. I don't really get that but what I had to do to get it to look like this again was actually create sd5 as a logical partition in order to list it as partition "5" then I attempted to convert it to swap space by using "mkswap /dev/sda5". But this failed with "device or resource busy". So I checked to see if it was mounted and it was not. At that point I was not sure what could be keeping me from converting the space into swap so I simply went back into fdisk and changed the ID to 0x82 to identify it as swap. So as of now I have a similar look to the original table. My 2 concerns now are :

1) When I tried to activate the swap space using "sudo swapon /dev/sda5" I still get device or resource busy.
2) I still have a jacked up fstab file and am not sure what I need to do to fix that.

project722 08-23-2014 06:41 AM

Also,

3) I am not sure the best way to go about reinstalling the boot loader since this is running in virtualbox. I have already passed sda1 the "bootable" flag using fdisk. Most everything I come across involves some kind of booting with a live cd to reinstall the BL. Is there another way to accomplish this without a reboot?

project722 08-23-2014 07:04 AM

Ok after running blkid it looks like that output matches the identifiers currently in fstab so I may be ok here.

sudo blkid
[sudo] password for brian:
/dev/sda1: UUID="1566d285-de09-408d-8b14-c43d82fe0dfa" TYPE="ext4"
/dev/sda5: UUID="e0de16fa-8e60-4237-af98-3ebaafb594e5" TYPE="swap"
brian@ubuntuvbox:~$

JeremyBoden 08-23-2014 07:49 AM

You don't really need to worry about swap.
Provided the appropriate line is commented-out of your fstab.
You can boot (and run) without any swap at all.

If it was me, I would have used dd to carefully copy my MBR to a file on a USB stick.


All times are GMT -5. The time now is 10:59 AM.