[prev in list] [next in list] [prev in thread] [next in thread] 

List:       voyage-linux
Subject:    [Voyage-linux] [PATCH 4/4] voyage-install: guess target disk from partition label
From:       Jim Cromie <jim.cromie () gmail ! com>
Date:       2012-09-22 17:19:18
Message-ID: 1348334358-23093-5-git-send-email-jim.cromie () gmail ! com
[Download RAW message or body]

Find VOYAGE_FS in mount output, and parse out values needed, ie:
TARGET_DISK, TARGET_PART.  Print the guess before prompting user to
accept or change the device.  New UI output is below, in context with
old output before and after.

Partitions information
major minor  #blocks  name

   8        0  976762584 sda
   8        1      48163 sda1
   8        2   10156032 sda2
   8        3  491423744 sda3
   8        4          1 sda4
   8        5     512000 sda5
   8        6  474618880 sda6
  11        0      64516 sr0
   8       16  976762584 sdb
   8       17      40131 sdb1
   8       18   15360000 sdb2
   8       19  348247765 sdb3
   8       20          1 sdb4
   8       21  589095486 sdb5
   8       22   24009111 sdb6
 252        0   52428800 dm-0
   8       32    3964464 sdc
   8       33    3964124 sdc1
 252        1   10289152 dm-1
 252        2  205062144 dm-2

guessing target: /dev/sdc1 on /run/media/jimc/VOYAGE_FS type ext2
ie:
	TARGET_DISK:	/dev/sdc
	TARGET_PART:	1
	MOUNT_POINT:	/run/media/jimc/VOYAGE_FS

Which device accesses the target disk [/dev/sdc]?

Which partition should I use on /dev/sdc for the Voyage system [1]?

Device information for /dev/sdc1
device        fs_type label    mount point       UUID
--------------------------------------------------------------------------------------
/dev/sdc1     ext2    VOYAGE_FS /run/media/jimc/VOYAGE_FS 61598f9f-ca5f-4a93-b8f5-44e9594e9263

Where can I mount the target disk [/mnt/cf]?

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 usr/local/sbin/voyage-install.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/usr/local/sbin/voyage-install.sh b/usr/local/sbin/voyage-install.sh
index 1837e40..74d245b 100755
--- a/usr/local/sbin/voyage-install.sh
+++ b/usr/local/sbin/voyage-install.sh
@@ -42,6 +42,22 @@ select_target_disk() {
 		echo
 	fi
 	
+	#print existing device with ROOT_LBL
+	guessdisk=`mount | grep $ROOT_LBL | cut -d\  -f1-5`
+	if [ -n "$guessdisk" ] ; then
+	    echo "guessing target: $guessdisk"
+	    MOUNTPT=`echo $guessdisk | cut -d\  -f3`
+	    guessdisk=`echo $guessdisk | cut -d\  -f1`
+	    guessdisk=`echo $guessdisk | sed -e 's/[0-9][0-9]*/ &/g'`
+	    TARGET_DISK=`echo $guessdisk | cut -d\  -f1`
+	    TARGET_PART=`echo $guessdisk | cut -d\  -f2`
+	    echo "ie:"
+	    printf "\tTARGET_DISK:\t$TARGET_DISK\n"
+	    printf "\tTARGET_PART:\t$TARGET_PART\n"
+	    printf "\tMOUNT_POINT:\t$MOUNTPT\n"
+	    echo ""
+	fi
+
 	while true
 	do
 		read_response "Which device accesses the target disk [$TARGET_DISK]? " a
-- 
1.7.11.4


_______________________________________________
Voyage-linux mailing list
Voyage-linux@list.voyage.hk
http://list.voyage.hk/mailman/listinfo/voyage-linux
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic