Re: swapping partitions including /
Previously Robert van der Meulen wrote:
> For the swapping part, you can use 'pivot_root', in the newer util-linux
> distributions. As far as i know, pivot_root is not in the debian version
> yet.
It has been added in version 2.11b-2. For those of you running testing
or stable I've attached a little pivot_root implementation I wrote
for personal use a while ago.
> A 'pivot_root . /tmp', when executed in /tmp will leave you with a /dev/sda5
> on /tmp, and /dev/sda9 on /.
More importantly, it will also change the cwd for processes that had cwd
set to root to the new root so you can safely unmount it.
> I use this to mount a reiserfs root-filesystem on an lvm volume.
Same here :)
Wichert.
--
_________________________________________________________________
/ Nothing is fool-proof to a sufficiently talented fool \
| wichert@cistron.nl http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0 2805 3CB8 9250 2FA3 BC2D |
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/syscall.h>
void usage() {
fprintf(stderr,
"Usage:\n"
" pivotroot <newroot> <oldroot>\n"
"\n"
"This will make <newroot> the new root filesystem and remount\n"
"the old one at <oldroot>.\n");
}
int main(int argc, char** argv) {
int res;
if (argc!=3) {
fprintf(stderr, "Invalid number of arguments\n");
usage();
exit(1);
}
if ((res=syscall(SYS_pivot_root, argv[1], argv[2]))==-1) {
perror("Error pivoting root");
exit(2);
} else if (res!=0) {
fprintf(stderr, "pivot_root failed with return code %d\n", res);
exit(3);
}
return 0;
}
Reply to: