Solved

reload partition table information

Posted on 2004-09-10
7
12,665 Views
Last Modified: 2010-05-18
Short :

How do I reload the partition table information w/o rebooting the system (VFAT) ?

Long:

I have deleted two (all) partitions from a second drive and then created one merged VFAT part. using FDISK, then used mkfs.vfat to format.
Now, how do I make linux (FC2 , kernel 2.6.x) to reload the partition information without rebooting the computer? Right now, when mounting /dev/hdb1 I find the old contents of the first partition I deleted, and that seems normal as that's the info it "remembers" .

thanks for any pointer

Kronos
0
Comment
Question by:kronostm
7 Comments
 
LVL 14

Author Comment

by:kronostm
Comment Utility
I think the following is normal behavior though annoying:

(parted) check 1
Warning: Partition 1 is 76316.563Mb, but the file system is 20002.776Mb.
Ignore/Cancel? c
(parted)
0
 
LVL 20

Assisted Solution

by:Gns
Gns earned 50 total points
Comment Utility
Hm, are we running into limitation of how big a vfat can raelly get here?

-- Glenn
0
 
LVL 23

Accepted Solution

by:
Mysidia earned 200 total points
Comment Utility
I think the best thing to do is to reboot.

You could try making a call to the ioctl facility provided by the kernel re-read the partition table
(if the drivers/kernel correctly support the operation for that device, this may do the reload)

be careful and make sure no filesystem or other process is mounted on, accessing or
going to use anything on the device in the meantime (this snippet won't try to check)

/* Assume this source file is named reread.c and you use GCC as your
   C compiler...  commands:  

    Replace /dev/hdb below with the proper device
    gcc -o reread reread.c
   ./reread
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/fs.h>
#include <fcntl.h>

#define DEVICE_NODE "/dev/hdb"
                                                                               
int main()
{
   int fd;
                                                                               
   sync (); /* Sync disks */
                                                                               
   if ((fd = open(DEVICE_NODE, O_RDONLY)) < 0) { perror("open");
           close(fd); return 0; }
   if (ioctl(fd, BLKRRPART) < 0)
           perror("unable to reload table");
   close(fd);
                                                                               
}
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 2

Expert Comment

by:Sunjith
Comment Utility
Linux fdisk usually calls the ioctl to reread the partition table when a new partition table is written to disk.
Are you sure that you wrote the new partition to disk after you modified the partition table in fdisk??
0
 
LVL 14

Author Comment

by:kronostm
Comment Utility

Thanks guys.



Gns .... don't think so .... I've used even bigger than 80GB FAT's  in linux
Actually I have a movie storage drive (160GB) and I wanted to test what does Windows 2000 says about a 160GB FAT partition. Well, it reads with no prob. but doesn't write more than 128GB. However ... comin' back to our FAT ... I don't think it's too big to be read.

Mysidia .... that's very interesting. I will try it today and let you know the result.

Sunjith .... yes, I am sure. Look at this:

Command (m for help): p
                                                                               
Disk /dev/hdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
                                                                               
   Device Boot      Start         End      Blocks   Id  System
/dev/hdb1               1        9729    78148161    c  W95 FAT32 (LBA)
0
 
LVL 14

Author Comment

by:kronostm
Comment Utility
As expected .... my fault :((  .... forgot to issue a param for FAT32:
 mkfs.vfat /dev/hdb1 -F 32
.... notice the -F 32 .... w/o it  I had a Fat16 part ... now it's clear what happened.
Gns asked me if we're running into any limitations of how big a FAT can get .... well ... I'm sure neither him nor me were thinking about FAT16 ... but it was an idea though.
Mysidia came with  a good functioning C program.
Now everything is working fine. (BTW ... the partition table IS reread by system immediately after creating the file system so my question is somehow useless ... it was my fault as I forgot to create a FAT32 and got instead a default FAT16 partition.
0
 

Expert Comment

by:Jemshi
Comment Utility
Best way to make fat filesystems on partitions is to do it from windows rather than from *nix.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now