AIX uninstall
Purpose: create ramdisk to be able to dd the running system, then shut it down when the files are already deleted from the disk(s).
Normally, you should either wipe the disks:
a) from the install CD's disk menu
b) from a (Linux) live CD
c) in another AIX (provided that you run at least a pv=clear to prevent the another system from recognizing the foreign rootvg)
d) physically when security/internal regulations demand it
But there are situations when the system must be just shut down and the disks must be cleared. For example, when you have no physical access to it...
First steps
Detach/delete datavg(s)
Delete users
Delete non-BOS filesystems, sysdump, etc
Unmirror rootvg, wipe freed mirror copy disks
Stop daemons
The desired state: system running on a single last disk with a minimum set of processes and filesystems
Creating a ramdisk
The mkramdisk command
Usage: mkramdisk [-u] Size[M|G]
Suffix 'M' to specify Size in Megabytes
Suffix 'G' to specify Size in Gigabytes
Default Size is in 512-byte blocks
-u Specifies that the ram disk that is created will not be pinned. (default = pinned)
Creation (1GB):
# mkramdisk 1024M
/dev/rramdisk0
Removal:
# rmramdisk /dev/rramdisk0
JFS2
# mkfs -V jfs2 -o log=INLINE /dev/ramdisk0
mkfs: destroy /dev/ramdisk0 (yes)? y
logform: Format inline log for <y>?
File system created successfully.
1040148 kilobytes total disk space.
Device /dev/ramdisk0:
Standard empty filesystem
Size: 2080296 512-byte (DEVBLKSIZE) blocks
# mount -olog=INLINE /dev/ramdisk0 /ram
JFS
# mkfs -V jfs /dev/ramdisk0
mkfs: destroy /dev/ramdisk0 (yes)? y
Device /dev/ramdisk0:
Standard empty filesystem
Size: 2097152 512-byte (UBSIZE) blocks
Initial Inodes: 262144
# mount -V jfs -o nointegrity /dev/ramdisk0 /ram
# df -Ig /ram
Filesystem GB blocks Used Free %Used Mounted on
/dev/ramdisk0 1.00 0.03 0.97 4% /ram
Errors, mistakes
# mount /dev/ramdisk0 /ram
mount: 0506-322 Cannot determine log device to use for /dev/ramdisk0 (/ram).
- You didn't specify -V jfs (JFS) or -olog=INLINE (JFS2).
# mount -olog=INLINE /dev/ramdisk0 /ram
Replaying log for /dev/ramdisk0.
Failure replaying log: -8
mount: 0506-324 Cannot mount /dev/ramdisk0 on /ram: The media is not formatted or the format is not correct.
- JFS doesn't support inline log.
# mount /dev/rramdisk0 /ram
mount: 0506-324 Cannot mount /dev/rramdisk0 on /ram: A system call received a parameter that is not valid.
- You shouldn't use the raw device for the file system commands (mkfs or mount)
The chroot environment
mkdir -p /ram/usr/bin /ram/usr/sbin /ram/usr/lib
cp /usr/sbin/halt /ram/usr/sbin
cp /usr/bin/ksh /ram/usr/bin
cp /usr/lib/libc.a /ram/usr/lib
cp /usr/lib/libcrypt.a /ram/usr/lib
## kernel
ls -l /unix
mkdir -p /ram/usr/lib/boot
cp /usr/lib/boot/unix_64 /ram/usr/lib/boot/unix
cp /usr/lib/boot/unix_64 /ram/unix
## test
chroot /ram /usr/bin/ksh
cp /usr/bin/find /ram/usr/bin
cp /usr/bin/ldd /ram/usr/bin
## why ldd oesn't work inside the chroot?
head -1 /ram/usr/bin/ldd
vi /ram/usr/bin/ldd
## #!/bin/ksh -> #!/usr/bin/ksh
## It isn't very important, as ldd needs a ton of textproc and other binaries...
## devices
mkdir /ram/dev
cd /ram/dev
mknod null c 2 2
mknod console c 4 0
chroot /ram /usr/bin/ksh
mkdir /ram/tmp
Deleting the last rootvg disk
# bootlist -m normal ent0
# bootlist -m normal -o
ent0
# chpv -c hdisk0
# cp /usr/bin/cat /ram/usr/bin
# cat > dd.sh
dd if=/dev/zero of=/dev/rhdisk0 bs=1m 2>&1 > /ram/RESULT
# nohup sh ./dd.sh &
[1] 184534
# chroot /ram /usr/bin/ksh
# echo *
FILE RESULT dd.sh dev lost+found nohup.out tmp unix usr
# cat RESULT
#
# find RESULT -ls
21 0 -rw-r--r-- 1 0 3 0 Oct 10 15:07 RESULT