Tagged: UNIX

Creating ISO images from CD or DVD

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

1. Reading the block size and the volume size:
# isoinfo -d -i /dev/sr0 | grep -i -E 'block size|volume size' Logical block size is: 2048 Volume size is: 327867

2. Running dd with the parameters for block size and volume size: # dd if=/dev/sr0 of=/tmp/test.iso bs= count= status=progress

That's all!
-gibb

FreeBSD: gptzfsboot: No ZFS pools located, can’t boot on FreeBSD 11-RELEASE

Last time (a few years back) when I tried to install FreeBSD with zfs on my HP Pavilion dm3-1130us notebook, I got the following error message during the boot: gptzfsboot: error 66 lba 48 error 72 gptzfsboot: error 66 lba 0 gptzfsboot: error 66 lba 1 gptzfsboot: No ZFS pools located, can't boot.

I searched around for a solution but couldn't find any so I gave up on FreeBSD.

Years after, meaning recently, I gave FreeBSD 11-RELEASE a new shot, hoping that zfs boot up problem was resolved by now. *BAM* I got the same error after installing it with zfs. For desperation, I searched again and again. Tried building partition table manually, updating bootcode after the installation, etc... But nothing worked... I even tried TrueOS (FreeBSD with zfs and more) but got the same problem after the installation. Sob...

But finally, I found a solution (sort of)!!!

Here is what I tried. I don't think the installation medium makes difference but I used a USB boot image.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Step 1) Download the FreeBSD memstick image. Find the latest release version (as of this writing, it's 11.0) from the freebsd.org ftp site.

Step 2) dd the memstick image to a USB memory stick. The USB device name could be different depending on which OS you are using, but for FreeBSD, I read somewhere that said you need to use FreeBSD to make a bootable USB memory stick. So, I installed FreeBSD 11-RELEASE with UFS and ran the command: # dd if=FreeBSD-11.0-RELEASE-amd64-memstick.img of=/dev/da0 bs=1M conv=sync

Step 3)Reboot with the USB memory stick inserted. Leave the USB memory stick attached to the notebook, rebooted the system. FreeBSD will boot and it'll present with three options; Install, Shell or Live CD. I chose Install.

Step 4) Install the system but at the partitioning, choose Auto ZFS:

Here is the zfs configuration:

Step 5) Go through the rest of the installation until it asks you for the last manual configuration. Select Yes to update gptzfsboot and bootdcode:

Step 6) Get the updated gptzfsboot_hp from the FreeBSD Bugzilla. The url is listed in Allan Jude at Comment 29. If you are not configured its networking, enable dhcp client: # dhclient re0

Then download gptzfsboot_hp by fetching from the location # fetch --no-verify-peer http://trooper.hml3.scaleengine.net/gptzfsboot_hp

Step 7) Rename gptzfsboot_hp to gptzfsboot and move it to /boot.

Step 8) Update the bootcode. Make sure you are using /boot/pmbr for the GPT partition type: # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

Step 9) Make sure the partition scheme and it's for the ada0 disk. Occasionally, its disk ID is changed to something like diskid/DISK-.... If this happens, use that disk name/id instead of ada0 at the Step 8.

Step 10) Reboot the system.

After the reboot, you would see the prompt for GELI Passphrase. However, this solution solved the boot up problem with ZFS. I still see the error 66 with lba: gptzfsboot: error 66 lba 48 error 72 gptzfsboot: error 66 lba 0 gptzfsboot: error 66 lba 1 GELI Passphrase for disk0p3:

After entering GELI passphrase correctly, voilĂ , you'll see the login prompt!

That's all!
-gibb

Linux: Getting to know `find` command

The find command is one of most important and much used command in my opinion. It's very useful because it not only finds files and directories with detailed options but also can execute additional commands (ex: mv, rm, etc...) on found items.

I'm ashamed to say this but, on the other day, I accidentally corrupted my external USB hard drive that had all of my back-up files! I used TestDisk hoping to fix its partition table but it didn't work. So I used PhotoRec to recover photos.

If you have used PhotoRec before, you know this but it does not recover files with original names. Instead, it creates a directory, recup_dir.[number], and put files with a unique names like f1175051952.jpg. In my case, it created more than 3000 directories with image files scattered all over. The find command came in handy!

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibility of end result after following these steps (although I will try to help if you send me your questions/problems).

Finding all .jpg files and ignoring case:

Find all files whose name has .jpg extension in the current directory and below. $ find . -iname "*.jpg" -print

Finding and moving all .jpg files in one single pass:

Find all files whose name has .jpg extension in the current directory and below and move them to /mnt/jpg. $ find . -iname "*.jpg" -type f -exec mv {} /mnt/jpg \;

Finding and removing empty directories:

Find empty directory in the current directory and below and remove them. $ find . -type d -empty -exec rmdir {} \;

Finding files with no extensions:

Find files whose name does not contain extension in the current directory and below. $ find . -type f ! -name "*.*"

Finding files without .jpg extension:

Find files whose name does not have .jpg extension in the current directory and below. $ find . -type f ! -name "*.jpg"

Here is some other useful options.

Finding files with 777 permissions:

Find files whose permissions are 777 $ find . -type f ! -perm 0777 -print

Finding files based on user:

Find files which belong to user ubyt3m3 under /home directory. $ find /home -user ubyt3m3 -print

Finding accessed files in last 1 hour:

Find files which are accessed in last 1 hour under /var/log directory. $ find /var/log -amin -60 -print

Finding last 7-14 days modified files:

Find files which are modified in last 1 hour under /home/www directory. $ find /home/www -mtime +7 -mtime -14 -print

That's all!
-gibb

FreeBSD 10 with Full Disk Encryption on UFS Filesystem

Since its release on 1/20/2014, I have been trying to install FreeBSD 10 on my HP Pavilion dm3-1130us notebook with ZFS because I wanted to utilize its full disk encryption; however, every time I try, it failed during the boot process with the following messages: gptzfsboot: error 66 lba 48 gptzfsboot: error 66 lba 1 gptzfsboot: No ZFS pools located, can't boot

I googled but couldn't find any solutions even now. If anyone knows how to resolve this, I'm all ears.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibility of end result after following these steps (although I will try to help if you send me your questions/problems).

So for now, I'm going to install it with full disk encryption on UFS instead. After many trial and errors, I found steps that worked on my system (thanks to BSD Now). I'll just list commands below just in case the site becomes unavailable in the future (it happens!).

Installation:

Follow the installation until the partition menu. Choose shell to manually configure the disk encryption before the OS is installed.

To view a list of disk devices, run: # sysctl kern.disks

With a blank disk, run: # gpart create -s gpt ada0

Or destroy existing one: # gpart destroy -F ada0

Create 3 partitions. The first is for the boot record, the second is an unencrypted /boot partition (from which the kernel is loaded) and the third is the large encrypted partition for the rest of the OS and files. # gpart add -t freebsd-boot -s 512k -a 4k ada0 # gpart add -t freebsd-ufs -l bootfs -s 1g -a 1m ada0 # gpart add -t freebsd-ufs -l encrypted -a 1m ada0

Install the bootcode: # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0

Encrypt the partition: # geli init -b -s 4096 ada0p3 Enter passphrase: Reenter passphrase:

Attach the device: # geli attach ada0p3 Enter passphrase: cryptosoft0: on motherboard GEOM_ELI: Device ada0p3.eli created GEOM_ELI: Encryption: AES-XTS 128 GEOM_ELI: Crypto: software

Format the partitions: # newfs -U /dev/ada0p2 # newfs -U /dev/ada0p3.eli

Mount the partitions: # mount /dev/ada0p3.eli /mnt # mkdir /mnt/unenc # mount /dev/ada0p2 /mnt/unenc # mkdir /mnt/unenc/boot # ln -s unenc/boot /mnt/boot

Create the fstab file: # vi /tmp/bsdinstall_etc/fstab ---------------------------------------------------- # Device Mountpoint FStype Options Dump Pass# /dev/ada0p2 /unenc ufs rw,noatime 1 1 /dev/ada0p3.eli / ufs rw,noatime 2 2

Automatically load the kernel modules that are required for booting from an encrypted volume: # vi /tmp/bsdinstall_boot/loader.conf ---------------------------------------------------- geom_eli_load="YES" vfs.root.mountfrom="ufs:ada0p3.eli"

Exit out and follow the rest of installation. After rebooting, it should prompt for passphrase.

However, on my system there was a bit of gotcha after the reboot: FreeBSD10_encryption

As you might see in above image, some kernel messages followed right after the passphrase prompt. I did not realize this for a while and made me think that the encryption failed (and it took me a while to figure out...). To confirm the encryption is working, press Enter. The passphrase prompt shows up again: GEOM_ELI: Wrong key for ada0p3. Tries left: 2. Enter passphrase for ada0p3:

That's all!
-gibb

AIX: HOWTO: Apply Patch(es)

This is a collection of AIX tips from the time I worked as system admin:

Disclaimer:
The information below is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others.

  1. Always run the inutoc command to ensure the installation subsystem will recognize the new fix packages you download. This command creates a new .toc file for the fix package. Run the inutoc command in the same directory where you downloaded the package filesets. For example, if you downloaded the filesets to /usr/sys/inst.images, run the following command: # inutoc /usr/sys/inst.images

  2. For selected updates
    To install selected updates from this package, use the following command: # smit update_by_fix

  3. For all updates
    To install all updates from this package that apply to the installed filesets on your system, use the following command: # smit update_all It is highly recommended that you apply all updates from this package.

  4. Reboot the system. A reboot is required for this update to take effect.
  5. That's all!
    -gibb