[clug] partition tables in memory

Kim Holburn kim.holburn at anu.edu.au
Sat Apr 16 08:11:12 GMT 2005


fdisk says this:

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.
Syncing disks.


On 2005 Apr 16, , at 5:11 PM, Steve Walsh wrote:

> You could try making a call to the ioctl facility provided by the 
> kernel
> re-read the partition table.
> 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 (code below won't
> check.)
>
>
> ********BIG ARSE DISCLAIMER*****
> I'm not a kernel or C programmer. I can't remember where I got this 
> code
> from, but it's in a closed case marked "reloading partition tables", 
> so if
> this doesn't work, and b0rks your box, I'm sorry, I'll buy you a beer 
> to cry
> into, but that's as far as willing to wave various parts of the 
> anatomy in
> the direction of liability I will go.
> ********End Big Arse Disclaimer********
>
>
> /* 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);
>
> }
>
> HTH
>
> Steve
> -----Original Message-----
> From: Kim Holburn
> Sent: Saturday, 16 April 2005 2:37 PM
> To: CLUG List
> Subject: [clug] partition tables in memory
>
>
> Hi,
>
> I have a linux server which needed more swap.  I added a new swap
> partition wrote the new partition table but it doesn't show up in
> /proc/partitions so I can't mkswap etc.
> # mkswap  /dev/sda8
> /dev/sda8: No such device or address
>
> Is there any way to get the kernel to reread the partition table or do
> I have to do the windows thing and reboot (and lose my uptime;-( )?
>
> Dell debian stable kernel 2.4.26 #1 SMP
>
> Kim
> --
> Kim Holburn
> Network Manager,  National ICT Australia Ltd.
> Ph: +61 2 61258620 M: +61 417820641 F: +61 2 6230 6121 aim://kimholburn
> Email: kim.holburn at anu.edu.au  - PGP Public Key on request
> callto://kholburn
> Cacert Root Cert: http://www.cacert.org/index.php?id=16 ->
> http://www.cacert.org/cacert.crt
> Aust. Spam Act: To stop receiving mail from me: reply and let me know.
>
> Use ISO 8601 dates [YYYY-MM-DD]
> http://www.saqqara.demon.co.uk/datefmt.htm
> Democracy imposed from without is the severest form of tyranny.
>                            -- Lloyd Biggle, Jr. Analog, Apr 1961
>
> --
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux
>
> -- 
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux
>
-- 
Kim Holburn
Network Manager,  National ICT Australia Ltd.
Ph: +61 2 61258620 M: +61 417820641 F: +61 2 6230 6121 aim://kimholburn
Email: kim.holburn at anu.edu.au  - PGP Public Key on request  
callto://kholburn
Cacert Root Cert: http://www.cacert.org/index.php?id=16 -> 
http://www.cacert.org/cacert.crt
Aust. Spam Act: To stop receiving mail from me: reply and let me know.

Use ISO 8601 dates [YYYY-MM-DD] 
http://www.saqqara.demon.co.uk/datefmt.htm
Democracy imposed from without is the severest form of tyranny.
                           -- Lloyd Biggle, Jr. Analog, Apr 1961



More information about the linux mailing list