LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2014, 07:48 AM   #1
project722
Member
 
Registered: Jun 2009
Posts: 53

Rep: Reputation: 0
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
 
Old 08-22-2014, 08:10 AM   #2
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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.
 
Old 08-22-2014, 09:46 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,056

Rep: Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915
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".
 
Old 08-22-2014, 10:50 AM   #4
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.
 
Old 08-22-2014, 12:00 PM   #5
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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
 
Old 08-22-2014, 04:54 PM   #6
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.
 
Old 08-22-2014, 05:21 PM   #7
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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!
 
Old 08-22-2014, 09:34 PM   #8
JeremyBoden
Senior Member
 
Registered: Nov 2011
Distribution: Debian
Posts: 1,026

Rep: Reputation: 203Reputation: 203Reputation: 203
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)
 
Old 08-22-2014, 11:53 PM   #9
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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
 
Old 08-23-2014, 12:28 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,145

Rep: Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351
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 View Post
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.

Last edited by rknichols; 08-23-2014 at 12:43 AM. Reason: Strike out "probably"
 
Old 08-23-2014, 06:06 AM   #11
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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.
 
Old 08-23-2014, 07:21 AM   #12
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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.
 
Old 08-23-2014, 07:41 AM   #13
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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?
 
Old 08-23-2014, 08:04 AM   #14
project722
Member
 
Registered: Jun 2009
Posts: 53

Original Poster
Rep: Reputation: 0
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:~$
 
Old 08-23-2014, 08:49 AM   #15
JeremyBoden
Senior Member
 
Registered: Nov 2011
Distribution: Debian
Posts: 1,026

Rep: Reputation: 203Reputation: 203Reputation: 203
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.

Last edited by JeremyBoden; 08-23-2014 at 08:51 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
altered partition table, Grub2 will not load, how-to chroot? kyrand0047 Linux - General 11 02-25-2011 05:57 PM
ext3 filesystem repair: partition table munched. mrspiffy Linux - Newbie 2 10-23-2008 02:29 AM
Modify partition table without unmounting filesystem s1k Linux - Software 3 05-08-2008 11:35 AM
Problem in creating filesystem for newly created partition. appas Linux - Software 2 08-21-2004 04:39 AM
Slack 10: S-ATA = "No partition table or unknown signature on partition table"? dissolved soul Slackware - Installation 11 08-05-2004 03:12 PM


All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration