![다시 시작하지 않고 chroot 후 sys/fs/cgroup/systemd 제거](https://linux55.com/image/110810/%EB%8B%A4%EC%8B%9C%20%EC%8B%9C%EC%9E%91%ED%95%98%EC%A7%80%20%EC%95%8A%EA%B3%A0%20chroot%20%ED%9B%84%20sys%2Ffs%2Fcgroup%2Fsystemd%20%EC%A0%9C%EA%B1%B0.png)
배경:ZFS-on을 활성화하기 위해 썸 드라이브("소스 드라이브")에서 ZFS 포맷 드라이브("대상 드라이브")로 일반 LVM-on-LUKS Debian 9("Stretch") 설치를 복사하는 방법을 탐색 중입니다. -LUKS 설치 . 내 프로세스는 다음을 기반으로 합니다.이 가이드.* ZFS 측면은 제가 해결하려는 문제와 관련이 없다고 생각하지만 중요한 경우를 대비해 언급합니다.
프로세스의 일부로 소스 드라이브에서 Stretch를 실행할 때 /
대상 ZFS 루트( ) 파일 시스템을 마운트합니다 /mnt
. 그런 다음 재귀적으로 바인딩합니다.
/dev
도착하다/mnt/dev
/proc
도착하다/mnt/proc
/sys
도착하다/mnt/sys
.
그런 다음 /mnt
.
(나중에 chroot할 때 , 등을 실행하여 파티션의 내용을 구성할 /mnt
계획입니다 .)update-initramfs
update-grub
/boot
그러다가 그만 두었고 chroot
문제가 시작되었습니다. 제거할 수 있다는 것을 알았 /mnt/dev
습니다 /mnt/proc
.하지만/mnt/sys
. 후자는 /mnt/sys/fs/cgroup/systemd
시스템이 어떤 이유로 "사용 중"이라고 생각하는 을 포함하고 있기 때문에 제거를 거부합니다. ZFS 드라이브를 다시 포맷하고 재부팅하면 문제가 해결되었지만 학습 및 문서화 프로세스의 반복 속도가 크게 느려졌습니다.
내 질문은 다음과 같습니다
- /mnt/sys
재부팅하지 않고 chroot 후 제거하는 방법은 무엇입니까?
- umount: /mnt/sys/fs/cgroup/systemd: target is busy
failure()가 예상됩니까? 그렇지 않은 경우 어떤 소프트웨어에 대해 버그 보고서를 제출해야 합니까?제거,cgroup,체계, 이것리눅스 커널, 또는 다른 것?
이것은 (내 생각에는)최소한의 작업 예. (이것을 재현하는 데 어려움이 있고 제가 한 단계를 놓쳤다고 생각하시면 알려주세요.) 먼저 상용구는 다음과 같습니다.
# Activate the ZFS kernel module
/sbin/modprobe zfs
# Set variables
BOOT_POOL=bpool
ROOT_POOL=rpool
DIRS_TO_COPY=(boot bin etc home lib lib64 opt root sbin srv usr var)
FILES_TO_COPY=(initrd.img initrd.img.old vmlinuz vmlinuz.old)
VIRTUAL_FILESYSTEM_DIRS=(dev proc sys)
## Partition target drive
# 1MB BIOS boot partition
sgdisk -a2048 -n1:2048:4095 -t1:EF02 $1 -c 1:"bios_boot_partition"
wait
# 510MB partition for /boot ZFS filesystem
sgdisk -a2048 -n2:4096:1052671 -t2:BF07 $1 -c 2:"zfs_boot_partition"
wait
# Remaining drive space, except the last 510MiB in case of future need:
# partition to hold the LUKS container and the root ZFS filesystem
sgdisk -a2048 -n3:1052672:-510M -t3:8300 $1 -c 3:"luks_zfs_root_partition"
wait
# Before proceeding, ensure /dev/disk/by-id/ knows of these new partitions
partprobe
wait
# Create the /boot pool
zpool create -o ashift=12 \
-O atime=off \
-O canmount=off \
-O compression=lz4 \
-O normalization=formD \
-O mountpoint=/boot \
-R /mnt \
$BOOT_POOL "$1"-part2
wait
# Create the LUKS container for the root pool
cryptsetup luksFormat "$1"-part3 \
--hash sha512 \
--cipher aes-xts-plain64 \
--key-size 512
wait
# Open LUKS container that will contain the root pool
cryptsetup luksOpen "$1"-part3 "$DRIVE_SHORTNAME"3_crypt
wait
# Create the root pool
zpool create -o ashift=12 \
-O atime=off \
-O canmount=off \
-O compression=lz4 \
-O normalization=formD \
-O mountpoint=/ \
-R /mnt \
$ROOT_POOL /dev/mapper/"$DRIVE_SHORTNAME"3_crypt
wait
# Create ZFS datasets for the root ("/") and /boot filesystems
zfs create -o canmount=noauto -o mountpoint=/ "$ROOT_POOL"/debian
zfs create -o canmount=noauto -o mountpoint=/boot "$BOOT_POOL"/debian
# Mount the root ("/") and /boot ZFS datasets
zfs mount "$ROOT_POOL"/debian
zfs mount "$BOOT_POOL"/debian
# Create datasets for subdirectories
zfs create -o setuid=off "$ROOT_POOL"/home
zfs create -o mountpoint=/root "$ROOT_POOL"/home/root
zfs create -o canmount=off -o setuid=off -o exec=off "$ROOT_POOL"/var
zfs create -o com.sun:auto-snapshot=false "$ROOT_POOL"/var/cache
zfs create "$ROOT_POOL"/var/log
zfs create "$ROOT_POOL"/var/mail
zfs create "$ROOT_POOL"/var/spool
zfs create -o com.sun:auto-snapshot=false -o exec=on "$ROOT_POOL"/var/tmp
zfs create "$ROOT_POOL"/srv
zfs create -o com.sun:auto-snapshot=false -o exec=on "$ROOT_POOL"/tmp
# Set the `bootfs` property. ***TODO: IS THIS CORRECT???***
zpool set bootfs="$ROOT_POOL"/debian "$ROOT_POOL"
# Set correct permission for tmp directories
chmod 1777 /mnt/tmp
chmod 1777 /mnt/var/tmp
이것이 문제의 핵심 부분입니다:
# Copy Debian install from source drive to target drive
for i in "${DIRS_TO_COPY[@]}"; do
rsync --archive --quiet --delete /"$i"/ /mnt/"$i"
done
for i in "${FILES_TO_COPY[@]}"; do
cp -a /"$i" /mnt/
done
for i in "${VIRTUAL_FILESYSTEM_DIRS[@]}"; do
# Make mountpoints for virtual filesystems on target drive
mkdir /mnt/"$i"
# Recursively bind the virtual filesystems from source environment to the
# target. N.B. This is using `--rbind`, not `--bind`.
mount --rbind /"$i" /mnt/"$i"
done
# `chroot` into the target environment
chroot /mnt /bin/bash --login
# (Manually exit from the chroot)
# Delete copied files
for i in "${DIRS_TO_COPY[@]}" "${FILES_TO_COPY[@]}"; do
rm -r /mnt/"$i"
done
# Remove recursively bound virtual filesystems from target
for i in "${VIRTUAL_FILESYSTEM_DIRS[@]}"; do
# First unmount them
umount --recursive --verbose --force /mnt/"$i" || sleep 0
wait
# Then delete their mountpoints
rmdir /mnt/"$i"
wait
done
마지막 단계에서 다음을 얻습니다.
umount: /mnt/sys/fs/cgroup/systemd: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)
도움이 되는 경우: findmnt
전체 sys
설치 트리를 두 번 표시합니다(한 번은 에 /sys
, 한 번은 ) /mnt/sys
.
*ZFS의 데비안 Jessie Root,CC-SA 3.0, 리처드 라지, 조지 멜리코프.
답변1
mount --make-rslave /mnt/"$i"
이러한 마운트 지점에 대해 올바른 전파 플래그가 설정되도록 첫 번째 마운트 명령 뒤에 이를 추가 해야 합니다 .
chroot 환경 내에서 변경된 사항으로부터 호스트를 보호하고 귀하와 같은 차단 상황을 방지하는 데 도움이 됩니다.