mirror of
https://github.com/lingble/talos.git
synced 2026-03-20 04:03:37 +00:00
refactor(init): remove unnecessary unmount/mount (#246)
This commit is contained in:
@@ -51,8 +51,7 @@ func initram() error {
|
||||
return err
|
||||
}
|
||||
// Setup logging to /dev/kmsg.
|
||||
var f *os.File
|
||||
f, err := kmsg("[talos] [initramfs]")
|
||||
_, err := kmsg("[talos] [initramfs]")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -86,14 +85,8 @@ func initram() error {
|
||||
if err := rootfs.Prepare(constants.NewRoot, data); err != nil {
|
||||
return err
|
||||
}
|
||||
// Unmount the ROOT and DATA block devices.
|
||||
log.Println("unmounting the ROOT and DATA partitions")
|
||||
if err := mount.Unmount(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Perform the equivalent of switch_root.
|
||||
log.Println("entering the new root")
|
||||
f.Close() // nolint: errcheck
|
||||
if err := switchroot.Switch(constants.NewRoot); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -82,13 +82,10 @@ func getDev(fd int) (dev uint64, err error) {
|
||||
return stat.Dev, nil
|
||||
}
|
||||
|
||||
// Switch performs a switch_root equivalent. See
|
||||
// Switch performs a switch_root. The caller must ensure that the ROOT and DATA
|
||||
// partitions are already mounted. See
|
||||
// https://github.com/karelzak/util-linux/blob/master/sys-utils/switch_root.c
|
||||
func Switch(s string) error {
|
||||
// Mount the ROOT and DATA block devices at the new root.
|
||||
if err := mount.Mount(s); err != nil {
|
||||
return errors.Wrap(err, "error mounting block device")
|
||||
}
|
||||
// Move the special mount points to the new root.
|
||||
if err := mount.Move(s); err != nil {
|
||||
return errors.Wrap(err, "error moving special devices")
|
||||
|
||||
Reference in New Issue
Block a user