fosslinux / live-bootstrap

Use of a Linux initramfs to fully automate the bootstrapping process
500 stars 35 forks source link

clean up tmp/ more strictly on pre-bootstrap failures #262

Closed bittorf closed 5 months ago

bittorf commented 1 year ago

$ ./rootfs.py --qemu --external-sources

Bootstrapping x86 -- SysA
[sudo] Passwort für bastian: 
mke2fs 1.46.6 (1-Feb-2023)
Discarding device blocks: done                            
Creating filesystem with 2096896 4k blocks and 524288 inodes
Filesystem UUID: 63f8e09f-6955-4a2e-a2f1-3205de645291
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

Downloading: autoconf-2.71.tar.xz
Downloading: nss-3.86.tar.gz
Downloading: libffi-3.3.tar.gz
...
Downloading: gnulib-7daa86f.tar.gz
Traceback (most recent call last):
  File "/home/bastian/software/live-bootstrap/./rootfs.py", line 225, in <module>
    main()
  File "/home/bastian/software/live-bootstrap/./rootfs.py", line 145, in main
    bootstrap(args, system_a, system_c, tmpdir)
  File "/home/bastian/software/live-bootstrap/./rootfs.py", line 210, in bootstrap
    system_c.prepare(create_disk_image=True)
  File "/home/bastian/software/live-bootstrap/sysc.py", line 44, in prepare
    self.get_packages(source_manifest)
  File "/home/bastian/software/live-bootstrap/lib/sysgeneral.py", line 75, in get_packages
    path = self.download_file(line[2], line[1], line[3])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bastian/software/live-bootstrap/lib/sysgeneral.py", line 67, in download_file
    raise requests.HTTPError("Download failed.")
requests.exceptions.HTTPError: Download failed.
Unmounting sysc
umount: sysc: nicht eingehängt
Bootstrapping failed
Exception ignored in: <function Tmpdir.__del__ at 0x7ff1a821b920>
Traceback (most recent call last):
  File "/home/bastian/software/live-bootstrap/lib/tmpdir.py", line 43, in __del__
    umount(path)
  File "/home/bastian/software/live-bootstrap/lib/utils.py", line 48, in umount
    run('sudo', 'umount', '--recursive', target, **kwargs)
  File "/home/bastian/software/live-bootstrap/lib/utils.py", line 26, in run
    sys.exit(1)
SystemExit: 1

OK, download error? try again: $ ./rootfs.py --qemu --external-sources

Bootstrapping x86 -- SysA
[sudo] Passwort für bastian: 
mke2fs 1.46.6 (1-Feb-2023)
/dev/loop3p1 contains a ext4 file system
    last mounted on Sat Mar 11 13:10:34 2023
Proceed anyway? (y,N) y
Discarding device blocks: done                            
Creating filesystem with 2096896 4k blocks and 524288 inodes
Filesystem UUID: 05c0ce8a-2689-4171-ad88-572ad471b4d4
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

Traceback (most recent call last):
  File "/home/bastian/software/live-bootstrap/./rootfs.py", line 225, in <module>
    main()
  File "/home/bastian/software/live-bootstrap/./rootfs.py", line 145, in main
    bootstrap(args, system_a, system_c, tmpdir)
  File "/home/bastian/software/live-bootstrap/./rootfs.py", line 210, in bootstrap
    system_c.prepare(create_disk_image=True)
  File "/home/bastian/software/live-bootstrap/sysc.py", line 40, in prepare
    rootfs_dir = self._tmpdir.mount_disk("sysc")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bastian/software/live-bootstrap/lib/tmpdir.py", line 85, in mount_disk
    os.mkdir(mountpoint)
FileExistsError: [Errno 17] File exists: '/home/bastian/software/live-bootstrap/tmp/sysc_mnt'
Detaching /dev/loop3
Removing /home/bastian/software/live-bootstrap/tmp

What to do now?

bittorf commented 1 year ago
bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C ls -l /home/bastian/software/live-bootstrap/tmp/sysc_mnt
total 16
drwx------ 2 root root 16384 Mar 11 13:10 lost+found

bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C sudo rm -fR /home/bastian/software/live-bootstrap/tmp/sysc_mnt
rm: cannot remove '/home/bastian/software/live-bootstrap/tmp/sysc_mnt/lost+found': Directory not empty

bastian@ryzen:~/software/live-bootstrap$ sudo chmod -R 777 /home/bastian/software/live-bootstrap/tmp/sysc_mnt

bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C sudo rm -fR /home/bastian/software/live-bootstrap/tmp/sysc_mnt
rm: cannot remove '/home/bastian/software/live-bootstrap/tmp/sysc_mnt/lost+found': Directory not empty

bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C ls -l /home/bastian/software/live-bootstrap/tmp/sysc_mnt
total 16
drwxrwxrwx 2 root root 16384 Mar 11 13:10 lost+found
11

bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C sudo rm -fR /home/bastian/software/live-bootstrap/tmp/sysc_mnt/lost+found
rm: cannot remove '/home/bastian/software/live-bootstrap/tmp/sysc_mnt/lost+found': Directory not empty

bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C sudo rm -fR /home/bastian/software/live-bootstrap/tmp/sysc_mnt/lost+found/

bastian@ryzen:~/software/live-bootstrap$ ls -l /home/bastian/software/live-bootstrap/tmp/sysc_mnt/lost+found/
insgesamt 0

bastian@ryzen:~/software/live-bootstrap$ lsattr tmp/sysc_mnt/
--------------e------- tmp/sysc_mnt/lost+found

bastian@ryzen:~/software/live-bootstrap$ mount | grep live-bootstrap
/dev/loop2p1 on /home/bastian/software/live-bootstrap/tmp/sysc_mnt type ext4 (rw,relatime)

bastian@ryzen:~/software/live-bootstrap$ sudo umount /dev/loop2p1

bastian@ryzen:~/software/live-bootstrap$ LC_ALL=C sudo rm -fR /home/bastian/software/live-bootstrap/tmp && echo OK
OK

...really, this should autorecover...

fosslinux commented 1 year ago

Yeah, the rootfs.py infra doesn't really respond properly to pre-bootstrap failures right now.

Googulator commented 5 months ago

With the abandonment of the "tmp" concept in #368 this is no longer applicable; the user is expected to use a new target directory for each bootstrap (or delete the previous one).