Solved

reload partition table information

Posted on 2004-09-10
7
12,691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Author Comment

by:kronostm
ID: 12026402
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
ID: 12027232
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
ID: 12031927
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 2

Expert Comment

by:Sunjith
ID: 12039380
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
ID: 12041622

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
ID: 12041701
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
ID: 12278119
Best way to make fat filesystems on partitions is to do it from windows rather than from *nix.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

733 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