aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManish Pandey <manish.pandey2@arm.com>2019-07-12 16:58:08 +0100
committersudipto paul <sudipto.paul@arm.com>2019-07-22 12:31:02 +0100
commit2faa4409da4703946f52cd4fc1e3351e5ba5dce9 (patch)
tree4f29211dc384dc0921176d579310c2cb24bb0ecf
parentf5f2b4e2e5510a1e6448323e98ae2275965dd68a (diff)
n1sdp: update Ubuntu RFS image creation and init script.
This patch adds following changes 1. Creating EXT4 instead of EXT3 partition. 2. Improve build time by reducing generated image size from 8GB to 2GB. 3. Increase partition size from 2GB to full disk size during first boot. 4. Create an user ubuntu:ubuntu, change root password to root. Change-Id: I247ea3ab5eb1843c3df711e02a1eaa57b22dfbff Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
-rwxr-xr-xbuild-grub.sh35
-rw-r--r--platforms/n1sdp/ubuntu/init15
2 files changed, 32 insertions, 18 deletions
diff --git a/build-grub.sh b/build-grub.sh
index 96a5fe7..a7b5277 100755
--- a/build-grub.sh
+++ b/build-grub.sh
@@ -74,9 +74,9 @@ create_imagepart ()
{
local image_name="$1"
local image_size="$2"
- local ext3part_name="$3"
+ local ext4part_name="$3"
cat fat_part >> $image_name
- cat $ext3part_name >> $image_name
+ cat $ext4part_name >> $image_name
(echo n; echo p; echo 1; echo $PART_START; echo +$((FAT_SIZE-1)); echo t; echo 6; echo n; echo p; echo 2; echo $((PART_START+FAT_SIZE)); echo +$(($image_size-1)); echo w) | fdisk $image_name
cp $image_name $PLATDIR
}
@@ -87,6 +87,8 @@ update_ubuntu ()
sed -ie 's/^root:x:0:/root::0:/' ./mnt/etc/passwd
# Set some nameserver, so apt-get will find its servers.
echo "nameserver 8.8.8.8" >> ./mnt/etc/resolv.conf
+ # Change the hostname to n1sdp
+ sed -ie 's/localhost.localdomain/n1sdp/' ./mnt/etc/hostname
# Copy Linux debian package
cp $OUTDIR/$PLATFORM/linux-image-n1sdp.deb ./mnt/
# Copy init for first boot of ubuntu
@@ -97,26 +99,25 @@ update_ubuntu ()
cp $UBUNTU_SETUP_DIR/interfaces ./mnt/etc/network/interfaces
}
-create_ext3part ()
+create_ext4part ()
{
- local ext3part_name="$1"
- local ext3size=$2
+ local ext4part_name="$1"
+ local ext4size=$2
local rootfs_file=$3
local extract_dir=$4
- echo "create_ext3part: ext3part_name = $ext3part_name ext3size = $ext3size rootfs_file = $rootfs_file"
- dd if=/dev/zero of=$ext3part_name bs=$BLOCK_SIZE count=$ext3size
+ echo "create_ext4part: ext4part_name = $ext4part_name ext4size = $ext4size rootfs_file = $rootfs_file"
+ dd if=/dev/zero of=$ext4part_name bs=$BLOCK_SIZE count=$ext4size
mkdir -p mnt
#umount if it has been mounted
if [[ $(findmnt -M "mnt") ]]; then
fusermount -u mnt
fi
- mkfs.ext3 -L Ubuntu-18.04 -F $ext3part_name
- fuse-ext2 $ext3part_name mnt -o rw+
+ mkfs.ext4 -L Ubuntu-18.04 -F $ext4part_name
+ fuse-ext2 $ext4part_name mnt -o rw+
cp $OUTDIR/$PLATFORM/Image ./mnt
sync
mkdir -p $TOP_DIR/build-scripts/$extract_dir
tar xf $TOP_DIR/build-scripts/prebuilts/$rootfs_file -C $TOP_DIR/build-scripts/$extract_dir
- chmod -R 750 $TOP_DIR/build-scripts/$extract_dir
cp -r $TOP_DIR/build-scripts/$extract_dir/* ./mnt
cp $PLATDIR/ramdisk.img ./mnt
update_ubuntu
@@ -161,12 +162,12 @@ do_package ()
local IMG_UBUNTU=grub-ubuntu.img
local BLOCK_SIZE=512
local SEC_PER_MB=$((1024*2))
- #FAT Partition size of 20MB and EXT3 Partition size 200MB
+ #FAT Partition size of 20MB and EXT4 Partition size 200MB
local FAT_SIZE_MB=20
- local EXT3_UBUNTU_SIZE_MB=8192
+ local EXT4_UBUNTU_SIZE_MB=2048
local PART_START=$((1*SEC_PER_MB))
local FAT_SIZE=$((FAT_SIZE_MB*SEC_PER_MB-(PART_START)))
- local EXT3_UBUNTU_SIZE=$((EXT3_UBUNTU_SIZE_MB*SEC_PER_MB-(PART_START)))
+ local EXT4_UBUNTU_SIZE=$((EXT4_UBUNTU_SIZE_MB*SEC_PER_MB-(PART_START)))
cp grubaa64.efi bootaa64.efi
@@ -180,15 +181,15 @@ do_package ()
dd if=/dev/zero of=$IMG_UBUNTU bs=$BLOCK_SIZE count=$PART_START
#Copy cfg file as grub.cfg
create_cfgfiles "fat_part" $GRUB_FS_CONFIG_FILE
- #create ext3_part with oe-lamp
- create_ext3part "ext3_part" $EXT3_UBUNTU_SIZE "ubuntu/bionic-base-arm64.tar.gz" "ubuntu"
+ #create ext4_part with oe-lamp
+ create_ext4part "ext4_part" $EXT4_UBUNTU_SIZE "ubuntu/bionic-base-arm64.tar.gz" "ubuntu"
# create image and copy into output folder
- create_imagepart $IMG_UBUNTU $EXT3_UBUNTU_SIZE "ext3_part"
+ create_imagepart $IMG_UBUNTU $EXT4_UBUNTU_SIZE "ext4_part"
fi
#remove intermediate files
rm -f fat_part
- rm -f ext3_part
+ rm -f ext4_part
fi
fi
}
diff --git a/platforms/n1sdp/ubuntu/init b/platforms/n1sdp/ubuntu/init
index 228c08b..96ca8a5 100644
--- a/platforms/n1sdp/ubuntu/init
+++ b/platforms/n1sdp/ubuntu/init
@@ -2,10 +2,16 @@
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -o remount,rw /
+chown -Rf root:root /
+chmod 777 /tmp
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH
apt-get update
-apt-get install -y isc-dhcp-client systemd udev apt-utils resolvconf grub-efi-arm64 kmod ifupdown net-tools vim initramfs-tools
+apt-get install -y isc-dhcp-client systemd udev apt-utils parted sudo resolvconf grub-efi-arm64 kmod ifupdown net-tools vim initramfs-tools openssh-server
+# Increase ext4 partition to full disk size
+parted /dev/sda resizepart 2 100%
+resize2fs /dev/sda2
+sync
ln -s /dev/null /etc/systemd/network/99-default.link
echo "nameserver 8.8.4.4" >> /etc/resolvconf/resolv.conf.d/head
echo "nameserver 8.8.8.8" >> /etc/resolvconf/resolv.conf.d/head
@@ -19,4 +25,11 @@ grub-install
sed -ie 's/^GRUB_TIMEOUT_STYLE=.*$/GRUB_TIMEOUT_STYLE=menu/; s/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=2/; s/GRUB_CMDLINE_LINUX_DEFAULT=.*$/GRUB_CMDLINE_LINUX_DEFAULT="earlycon"/' /etc/default/grub
update-grub
sync
+# change root password
+echo "root:root" | chpasswd
+# Create user ubuntu:ubuntu
+adduser ubuntu --gecos "ubuntu" --disabled-password
+echo "ubuntu:ubuntu" | chpasswd
+usermod -aG sudo ubuntu
+sync
bash