Jak preformatovat disk bez restartu, jde to? The kernel still uses the old table.

Dalibor Straka dast na panelnet.cz
Sobota Říjen 1 14:54:18 CEST 2005


On Sat, Oct 01, 2005 at 10:11:25AM +0200, Oqak wrote:
> Jak preformatovat disk bez restartu, jde to?
> 
> Nemohu prijit na to, jak killnu vsechny procesy a po vymene USB disku 
> (samozrejme to je datovy, nikoliv systemovy bootovaci disk) bez restartu 
> stroje preformatuju.
> 
> Pouzil jsem fdisk: nakonec mi napsal:
> 
> 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.
> 

No to je jasne, zabit vsechno podle lsof a aby jsi nemusel
poustet porad fdisk zkus todle:

/* zkompilovat a pak napsat 
   ./a.out /dev/hda
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/fs.h>
#include <fcntl.h>

int main(int argc,char **argv)
{
   int fd;

   sync (); /* Sync disks */

   if (argc == 2 && (fd = open(argv[1], O_RDONLY)) < 0) { perror("open");
           close(fd); return 0; }
   if (ioctl(fd, BLKRRPART) < 0)
           perror("unable to reload table");
   close(fd);
}

-- Dalibor


Další informace o konferenci Linux