How to clone entire VirtualBox OS to a new PC (real-hardware)?
Solution 1
Using converttoraw feature of virtual box and DD.
See: http://techokarma.blogspot.com/2008/10/v2p-virtual-to-physical-for-virtualbox.html
This assumes you have a reasonable knowledge of linux.
Solution 2
Quick trick to copy over a network: use linux netcat (nc). Using this method you do not have to convert to a raw image as dd will copy literally everything from the source drive.
Use your choice of linux live discs to boot both the physical machine and virtual machine, make sure both have network access and write down the IP addresses of both. Switch to root (sudo su). Find out what your drive paths are using fdisk -l
On the destination machine:
nc -l 10000 | dd of=/dev/sda bs=64
Command syntax:
nc -l <port#> | dd of=<destination drive> bs=<size in bytes>
Block size (bs) can be whatever you want, I try to keep it fairly small.
On the source virtual machine:
dd if=/dev/sda bs=64 | nc 192.168.0.100 10000
Command Syntax:
dd if=<source drive> bs=<size in bytes> | nc <destination ip> <destination port#>
Block size (bs) at the source and destination must match. I always set the destination machine up to reduce sending errors. There is no progress bar, just wait for the bash prompt to return and you are good to go. Remove the live discs and reboot.
Related videos on Youtube
pierpytom
Updated on September 18, 2022Comments
-
pierpytom over 1 year
I'm trying to setup push notifications both for Android and iOS using Worklight.
Thus far I have managed to set up the Google GCM (subscribing to the push seems to succeed), and I used the example in the IBM Worklight Getting Started page as main reference.
In the adapter, the
sendNotification
method needs theuserId
, but I don't know how to retrieve that. In the example, it is passed as an argument to the jar, but to me this doesn't seem as a feasible solution, since I need a real app with multiple users.I'm aware of the discussions on Stack Overflow:
- userID in getUserNotificationSubscription WORKLIGHT Pushnotification
- Worklight: Push notification without User ID
But still they don't answer to my doubts... In one of many attempts I tried to call
WL.Client.getUserName()
on the client, but it returnsnull
.As far as I understood, this is related to the security (and realm) settings of Worklight, but I suspect I didn't really catch the concept of user id. Given that I'm really new to mobile development (therefore many concepts are new for me, and I may be saying something wrong), my doubts are:
- is Worklight storing an user id which is different from the android user id (as an abstraction)?
- if yes, is this the reason why the security/realm is sometimes mentioned? how to pair these two user id (android/worklight) or, at least, work with the worklight user?
- since this one seems like a usual problem (pushing notifications to different users), is it possible that there is no example code online?
- which one should be the flow / architecture to follow, according to the user id? EG: user id needs to be stored into a realm, this realm as information about x and should be of type y, it will be used to z, etc... (still I have to figure out how to deal with realms)
My authenticationConfig.xml looks like this:
<staticResources> <resource id="subscribeServlet" securityTest="SubscribeServlet"> <urlPatterns>/subscribeSMS*;/receiveSMS*;/ussd*</urlPatterns> </resource> </staticResources> <securityTests> <!-- Added for pushing --> <mobileSecurityTest name="PushApplication-strong-mobile-securityTest"> <testUser realm="PushAppRealm"/> <testDeviceId provisioningType="none"/> </mobileSecurityTest> <customSecurityTest name="SubscribeServlet"> <test realm="SubscribeServlet" isInternalUserID="true"/> </customSecurityTest> </securityTests> <realms> <realm name="SampleAppRealm" loginModule="StrongDummy"> <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className> </realm> <realm name="SubscribeServlet" loginModule="rejectAll"> <className>com.worklight.core.auth.ext.HeaderAuthenticator</className> </realm> <!-- Added for pushing --> <realm loginModule="PushAppLoginModule" name="PushAppRealm"> <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className> </realm> </realms> <loginModules> <!-- Added for pushing --> <loginModule name="PushAppLoginModule"> <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className> </loginModule> <loginModule name="StrongDummy"> <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className> </loginModule> <loginModule name="requireLogin"> <className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className> </loginModule> <loginModule name="rejectAll"> <className>com.worklight.core.auth.ext.RejectingLoginModule</className> </loginModule> </loginModules>
And this one is the adapter (deviceSubscribeFunc is never called, I would expect the opposite):
WL.Server.createEventSource({ name: 'PushEventSource', onDeviceSubscribe: 'deviceSubscribeFunc', onDeviceUnsubscribe: 'deviceUnsubscribeFunc', securityTest:'PushApplication-strong-mobile-securityTest' }); // NEVER CALLED! function deviceSubscribeFunc(userSubscription, deviceSubscription){ WL.Logger.error(">> deviceSubscribeFunc"); // error is shown on the console, debug not WL.Logger.debug(userSubscription); WL.Logger.debug(deviceSubscription); } function deviceUnsubscribeFunc(userSubscription, deviceSubscription){ WL.Logger.error(">> deviceUnsubscribeFunc"); // error is shown on the console WL.Logger.debug(userSubscription); WL.Logger.debug(deviceSubscription); } function testCall(message) { WL.Logger.error("Client says: " + message); // error is shown on the console, debug not return { response : "hello client!" }; } function submitNotification(userId, notificationText){ var userSubscription = WL.Server.getUserNotificationSubscription('NotificationManager.PushEventSource', userId); if (userSubscription==null) return { result: "No subscription found for user :: " + userId }; var badgeDigit = 1; var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"}); WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText); WL.Server.notifyAllDevices(userSubscription, notification); return { result: "Notification sent to user :: " + userId }; }
Meanwhile the client subscribes to push in this way (toUI is a simple method which put a string into a new div in the UI):
var pushNotificationReceived = function(props, payload) { toUI("pushNotificationReceived invoked"); toUI("props :: " + JSON.stringify(props)); toUI("payload :: " + JSON.stringify(payload)); } if(WL.Client.Push) { var isSubscribed = WL.Client.Push.isSubscribed('myPush'); toUI("User is " + (isSubscribed? "" : "<u>not</u>")+ " subscribed.", confStyle); WL.Client.Push.onReadyToSubscribe = function() { toUI("Ready to subscribe, subscribing...", confStyle); WL.Client.Push.registerEventSourceCallback("myPush", "NotificationManager", "PushEventSource", pushNotificationReceived); } } else toUI("Push not available.", errStyle);
-
Admin about 13 yearsYou mean virtual to physical (V2P)?
-
Admin about 13 yearsYes, something like that but even easer way like creating bootable DVD of Virtual OS, something like recovery DVD..
-
AverageChau about 13 yearsthanks for the reply. Yes, v2p may work if I copy raw into a attached HDD. But what if I need to clone into a new laptop which has no OS installed? Do you think will it work if I copy raw into a USB pendrive then attach with new laptop and boot from Live-CD then do dd??
-
hookenz about 13 years@Himalay, Not sure about that.
-
pierpytom over 9 yearsHi Anton, I modified my question adding the source code. Is PushApplication-strong-mobile-securityTest what you mean by authenticating users (sorry for the dumb question)? I'm not storing any information, as first goal I would like to have the user requesting for subscription and then the server immediately pushing something to him, which I imagined to be not that hard... I understand the example you provided, but I don't know how to retrieve the user data (especially the user id to reuse in future)! :/
-
Idan Adar over 9 yearsPerhaps instead of delving into push notifications, you should read the security and authentication training modules, through which you will learn the basics of authentication in worklight. Which will then help you as your use those concepts in your application implementation, push included.
-
pierpytom over 9 yearsHi @idan-adar, I read the documentation you suggested. Since in the createEventSource I'm pointing to 'PushApplication-strong-mobile-securityTest' (which point to PushAppRealm), the missing step is authenticating in the UI using the PushAppRealm (at the moment I got a non validating login module). If I manage to do that, then Worklight will be able to send notification since the user is the one specified in PushAppRealm (which is used both from the adapter and the client), am I correct? Key should be having the client and the event source in the same realm.
-
Juri Adam over 9 yearsYou can actually get the progress of dd by running
kill -USR1 $PIDOfDD
or watching the transfer over time by runningwatch -n 10 kill -USR1 $PIDOfDD
link